/*
 * Copyright 2009 BioTeam Inc
 * 
 * Licensed under License GNU LESSER GENERAL PUBLIC LICENSE version 3.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.gnu.org/copyleft/lesser.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package net.bioteam.appweb.gwt.apps.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.widgets.Canvas;

public class AppWeb implements EntryPoint
{

	
	public void onModuleLoad()
	{

		StaticHolder.init();
		Canvas canvas=new Canvas();
		canvas.setWidth100();
		canvas.setHeight100();
		
		canvas.addChild(StaticHolder.loginPanel.loginPanel);
		canvas.addChild(StaticHolder.mainPanel);
		
		if (LoginHolder.isLogined())
		{
			StaticHolder.loginPanel.loginPanel.hide();
			StaticHolder.mainPanel.init();
			StaticHolder.mainPanel.show();
		} else
		{
			StaticHolder.loginPanel.loginPanel.show();
			StaticHolder.mainPanel.hide();	
		}
		canvas.draw();
		History.addHistoryListener(new ApplicationHistoryListener());
		
		if (LoginHolder.isLogined() && History.getToken()!=null && History.getToken().length()>0)
		{
			History.fireCurrentHistoryState();
		}
		
		//http://forums.smartclient.com/showthread.php?t=5469
		RootPanel.getBodyElement().removeChild(RootPanel.get("loadingWrapper").getElement());
		
//		Element element=RootPanel.get("loadingWrapper").getElement();
//		//RootPanel.detachNow(element);
//		Element parent=element.getParentElement();
//		parent.removeChild(element);
//		//RootPanel.setVisible(element, false);
	}
}
